#include "ros/ros.h"
#include "sensor_msgs/Range.h"

void leftCallback(const sensor_msgs::Range::ConstPtr &msg) {
    ROS_INFO("Left distance: [%f]", msg->range);
}

void centerCallback(const sensor_msgs::Range::ConstPtr &msg) {
    ROS_INFO("Center distance: [%f]", msg->range);
}

void rightCallback(const sensor_msgs::Range::ConstPtr &msg) {
    ROS_INFO("Right distance: [%f]", msg->range);
}

int main(int argc, char **argv) {
    ros::init(argc, argv, "cre_ultrasonic_subscriber");
    ros::NodeHandle nh;

    ros::Subscriber left_sub = nh.subscribe<sensor_msgs::Range>("left_distance", 1000, leftCallback);
    ros::Subscriber center_sub = nh.subscribe<sensor_msgs::Range>("center_distance", 1000, centerCallback);
    ros::Subscriber right_sub = nh.subscribe<sensor_msgs::Range>("right_distance", 1000, rightCallback);

    ros::spin();

    return 0;
}